//
//  AppDelegate.m
//  sinaWeibo
//
//  Created by 李江波 on 2016/11/13.
//  Copyright © 2016年 lijiangbo. All rights reserved.
//

#import "AppDelegate.h"
#import "WBTabController.h"
#import "WBWelcomeController.h"

#import "WBOAuthViewModel.h"

#import "WBStatuseDAL.h"

//#import "WBSendViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeRootVc:) name:kChangeRootVc object:nil];
    
    self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    
    self.window.backgroundColor = [UIColor whiteColor];
    
    WBTabController *VC = [[WBTabController alloc]init];
    
    WBWelcomeController *welcomeVc = [[WBWelcomeController alloc]init];
    
    
    self.window.rootViewController = [WBOAuthViewModel shared].isLogin ? welcomeVc : VC;
    
    [self.window makeKeyAndVisible];
    return YES;
}

-(void)changeRootVc:(NSNotification *)notification {

    Class clz = NSClassFromString(notification.object);
    
    [UIApplication sharedApplication].keyWindow.rootViewController = [[clz alloc]init];

}


-(void)applicationDidEnterBackground:(UIApplication *)application{

    [[WBStatuseDAL new] deleteCacheStatuses];
}


@end
